Parquet: add adaptive bloom filter sizing (PARQUET-2326)#16363
Open
raghav-reglobe wants to merge 1 commit into
Open
Parquet: add adaptive bloom filter sizing (PARQUET-2326)#16363raghav-reglobe wants to merge 1 commit into
raghav-reglobe wants to merge 1 commit into
Conversation
Add a new table property to enable parquet-mr's adaptive bloom filter sizing for Iceberg-managed Parquet writes: write.parquet.bloom-filter-adaptive-enabled (boolean, default false) When enabled, parquet-mr's `ColumnValueCollector.initBloomFilter` constructs an `AdaptiveBlockSplitBloomFilter` instead of `BlockSplitBloomFilter`. The adaptive variant evaluates N candidate filter sizes and picks the smallest that satisfies actual NDV at the configured FPP, instead of pre-allocating `bloom-filter-max-bytes`. Why: when bloom filter is enabled on a column without per-column NDV, parquet-mr's writer allocates a fixed `bloom-filter-max-bytes` buffer per column and writes it to disk regardless of how many values were inserted. For low-row-count writes this produces a file dominated by an empty bloom filter buffer. Empirical reduction on a Spark Structured Streaming + Iceberg pipeline: 5-row write with `bloom-filter-max-bytes=4194304` shrinks from 4,201,826 bytes to ~268,465 bytes (16x). Defaults to false to preserve current behavior. Operators opt in by setting `write.parquet.bloom-filter-adaptive-enabled=true`. Modifies the `createWriterFunc` write path (used by Spark/Flink data writes). The legacy `ParquetWriteBuilder` fallback path is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes are proposed in this pull request?
Add a new table property to enable parquet-mr's adaptive bloom filter sizing
(PARQUET-2326) for Iceberg-managed Parquet writes:
write.parquet.bloom-filter-adaptive-enabled(boolean, defaultfalse)When enabled, parquet-mr's
ColumnValueCollector.initBloomFilter()constructs anAdaptiveBlockSplitBloomFilterinstead ofBlockSplitBloomFilter. The adaptive variant evaluatesN candidate filter sizes and picks the smallest that satisfies actual NDV at the configured FPP,
instead of always pre-allocating
bloom-filter-max-bytes.Why are the changes needed?
Today, when bloom filter is enabled on a column without per-column NDV, parquet-mr's
ColumnValueCollector.initBloomFilter()allocates a fixedbloom-filter-max-bytesbuffer:The buffer is then written to disk via
ParquetFileWriter.serializeBloomFilters()regardless ofhow many values were inserted. For low-row-count writes this produces a file dominated by an
empty bloom filter.
Empirical observations from a Spark Structured Streaming + Iceberg pipeline (~720 silver
tables on warm 600s trigger):
bloom-enabled.col.id=true, max-bytes=4194304For workloads that produce frequent low-row-count microbatches (CDC streaming, frequent commits),
this is a significant storage and S3 PUT cost reduction.
How was this patch tested?
TestParquetAdaptiveBloomFiltercovers both:the property is not set
File sizes dropped 4 MiB → ~268 KiB on streaming microbatch outputs.
Backward compatibility
Default value is
false, so existing tables and writers see no behavior change.Operators opt in by setting
write.parquet.bloom-filter-adaptive-enabled=true.Scope
This PR modifies the createWriterFunc code path (used by Spark, Flink, and other engines for
data writes). The legacy
ParquetWriteBuilderfallback path (createWriterFunc == null) isunchanged. If maintainers want adaptive support on the legacy path as well, happy to extend in
a follow-up.
Files changed
core/src/main/java/org/apache/iceberg/TableProperties.java— add 1 constant + defaultparquet/src/main/java/org/apache/iceberg/parquet/Parquet.java— wire the property throughContext + use in WriteBuilder
parquet/src/test/java/org/apache/iceberg/parquet/TestParquetAdaptiveBloomFilter.java— new test